package com.data;

import java.util.ArrayList;
import java.util.List;

import com.entity.Student;

public class StudentData {
	
	public static void main(String[] args) {
		Student s = getLi();
		s = new Student();
		System.out.println(s.getJsonStr());
	}
	/**
	 * 
	 * <dl>
	 * 		<dt>作用：</dt>
	 *		<dd>根据学号找学生</dd>
	 * </dl>
	 * @param list 学生列表
	 * @param number 学号
	 * @return 对应学号的学生，若无该学号的学生返回null
	 */
	public static Student findByNumber(List<Student> list,String number) {
		for(Student student : list) {
			if( number != null 
					&& number.equals(student.getNumber())){
				return student;
			}
		}
		return null;
	}
	/**
	 * 
	 * <dl>
	 * 		<dt>作用：</dt>
	 *		<dd>返回初始的学生列表</dd>
	 * </dl>
	 * @return
	 */
	public static List<Student> getInitStdList(){
		List<Student> stdList = new ArrayList<Student>();
		stdList.add(getZhang());
		stdList.add(getLi());
		stdList.add(getWang());		
		return stdList;
	}
	/**
	 * 
	 * <dl>
	 * 		<dt>作用：</dt>
	 *		<dd>获得张三同学</dd>
	 * </dl>
	 * @return
	 */
	private static Student getZhang() {
		Student std = new Student();
		List<String> likeStd = new ArrayList<String>();
		likeStd.add("篮球");
		likeStd.add("足球");
		likeStd.add("音乐");
		//likeStd.add("美术");
		likeStd.add("摄影");
		likeStd.add("阅读");
		
		std.setNumber("162056101");
		std.setName("张三");
		std.setSex("男");
		std.setLike(likeStd);
		return std;
	}
	/**
	 * 
	 * <dl>
	 * 		<dt>作用：</dt>
	 *		<dd>获得李四同学</dd>
	 * </dl>
	 * @return
	 */
	private static Student getLi() {
		Student std = new Student();
		List<String> likeStd = new ArrayList<String>();
		//likeStd.add("篮球");
		//likeStd.add("足球");
		likeStd.add("音乐");
		//likeStd.add("美术");
		likeStd.add("摄影");
		likeStd.add("阅读");
		
		std.setNumber("162056102");
		std.setName("李四");
		std.setSex("女");
		std.setLike(likeStd);
		return std;
	}
	/**
	 * 
	 * <dl>
	 * 		<dt>作用：</dt>
	 *		<dd>获得王五同学</dd>
	 * </dl>
	 * @return
	 */
	private static Student getWang() {
		Student std = new Student();
		List<String> likeStd = new ArrayList<String>();
		likeStd.add("篮球");
		likeStd.add("足球");
		//likeStd.add("音乐");
		//likeStd.add("美术");
		likeStd.add("摄影");
		//likeStd.add("阅读");
		
		std.setNumber("162056103");
		std.setName("王五");
		std.setSex("男");
		std.setLike(likeStd);
		return std;
	}
}